package thread;

import java.text.SimpleDateFormat;
import java.util.Date;

//优先级

public class Test10_priority {
    public static void main(String[] args) {
        ShowTime2 task = new ShowTime2();
        Thread t = new Thread(task);
        t.setPriority(10);
        t.setName("t1");
        t.start();

        Thread t1 = new Thread(task,"t2");
        t1.setPriority(1);
        t1.start();
    }
}

class ShowTime2 implements Runnable{
    @Override
    public void run() {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 hh:mm:ss S");
        Date d = null;
        while (true){
            d = new Date();
            System.out.println(Thread.currentThread().getName()+"当前时间是："+simpleDateFormat.format(d));
            try {
                Thread.sleep(1000);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
        }
    }
}
